Next | Prev | Up | Top | Contents | Index

Using Deadline Scheduling

You can apply the deadline scheduling discipline to any process that must be assured of receiving a certain amount of execution time out of every interval, regardless of what other processes are running.

A process with normal or batch priority might enjoy a lot of execution time under light system load, but might be held idle for long periods under heavy system load. A process with a high, nondegrading priority is assured of getting all the execution time it can use, but it can monopolize resources. Deadline scheduling is best for a process that must have a certain minimum amount of time, but which should use little or none of the remainder of the time.

It requires no special privilege to assign deadline scheduling to a process. You can do it with the npri command. The following command schedules a shell script to execute at least 20% of each 100-millisecond interval.

npri -d 100,20 /usr/local/bin/deadline.sh

If the system cannot dedicate the requested amount of time, the command returns an error. Otherwise, the process is guaranteed the specified amount of time per interval.

Note: Execution time can be given at any point within the interval, and need not be continuous. Thus deadline scheduling cannot be used as the basis for a reliable real-time frame rate. A deadline guarantee is not inherited by processes created by fork() or sproc(). Each process must have deadline scheduling set for it independently.

The schedctl() call is used to set deadline scheduling within a process, and to choose a rule for what the process should do in the balance of the interval, after it has achieved its target percentage:

DL_ONLY

Process should be idle the rest of the period.

DL_ANY

Process should execute under the normal rules for its priority and nice value.
For an example of using schedctl() to set deadline scheduling, see "Deadline Scheduling Subroutines".

Note: The kernel uses a high-precision interval timer to measure usage under deadline scheduling. When deadline scheduling is in use, more frequent timer interrupts are generated. In some architectures this causes frequent kernel interrupts (see "Timer Management Without a Clock Comparator" and "Assigning the fasthz Processor").


Next | Prev | Up | Top | Contents | Index